﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HarveyNash.RefactoringAndCodeSmell.CodeSmell.ConditionalComplexity
{
    public static class After
    {
        public static IpodTouchGeneration GetIpodTouchGeneration(string modelNumber, DiskCapacity capacity)
        {
            Dictionary<string, IpodTouchGeneration> mapping = new Dictionary<string, IpodTouchGeneration>(StringComparer.OrdinalIgnoreCase);

            mapping["MA623LL/A"] = IpodTouchGeneration.FirstGeneration;
            mapping["MA627LL/A"] = IpodTouchGeneration.FirstGeneration;
            mapping["MB528LL/A"] = IpodTouchGeneration.SecondGeneration;
            mapping["MB531LL/A"] = IpodTouchGeneration.SecondGeneration;
            mapping["MC086LL/A"] = IpodTouchGeneration.ThirdGeneration;
            mapping["MC008LL/A"] = IpodTouchGeneration.ThirdGeneration;
            mapping["MC540LL/A"] = IpodTouchGeneration.FourthGeneration;
            mapping["MC544LL/A"] = IpodTouchGeneration.FourthGeneration;

            IpodTouchGeneration generation = IpodTouchGeneration.FirstGeneration;
            mapping.TryGetValue(modelNumber, out generation);

            if (generation == IpodTouchGeneration.FourthGeneration && capacity == DiskCapacity.Capacity8GB)
                generation = IpodTouchGeneration.ThirdGeneration;

            return generation;
        }
    }
}
